package pig.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

public class LoginCheckInterceptor extends HandlerInterceptorAdapter{
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		HttpSession session=request.getSession(false);
		if(session==null||session.getAttribute("login")==null){
			response.sendRedirect(request.getContextPath()+"/common/login_view.do");
			return false; // 컨트롤러 메서드 실행을 막는다. 
		}
		return true;
	}	
}







